﻿@using AntDesign.Charts
@using Title = AntDesign.Charts.Title

<Pie @ref="pie" Config="config1" />

@code {
    [Parameter]
    public double BaseSalary { get; set; }
    [Parameter]
    public double AddSalary { get; set; }
    [Parameter]
    public double CutSalary { get; set; }

    Object[] data1;
    Pie pie = new();
    readonly PieConfig config1 = new PieConfig {
            ForceFit = true,
            Title = new Title {
                Visible = true,
                Text = "您的薪水比例图"
            },
            Description = new Description {
                Visible = true,
                Text = "您的资薪组成占比如图所示"
            },
            Radius = 0.8,
            AngleField = "value",
            ColorField = "type",
            Label = new PieLabelConfig {
                Visible = true,
                Type = "inner"
            }
        };

    protected override void OnInitialized() {
    }

    protected override void OnParametersSet() {
        Console.WriteLine("在参数被设定的时候：" + BaseSalary);
        // 薪资资源
        data1 = new object[] {
            new {
                type = "基础工资",
                value = BaseSalary
            },
            new {
                type = "奖励工资",
                value = AddSalary
            },
            new {
                type = "扣除工资",
                value = CutSalary
            }

    };
        pie.UpdateChart(csConfig: config1, csData: data1);
        InvokeAsync(StateHasChanged);
    }

}
